/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yonsei.iwb.sdt.datastructure;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author JDK
 */
public class TargetInstanceSet extends Hashtable<Resource, Integer>{
    
    public int positive;
    public int negative;
//    private TargetInstanceValueSet tivs;
    
    private Hashtable<Integer, RDFNode> tivs = new Hashtable<Integer, RDFNode>();
    public TargetInstanceSet(){
        
    }   
    
//    public void setTargetInstanceValueSet(TargetInstanceValueSet tivs){
//        this.tivs = tivs;
//    }
//    
//    public TargetInstanceValueSet getTargetInstanceValueSet(){
//        return this.tivs;
//    }
    
    public void setTargetInstanceValueSet(Vector<RDFNode> vset){
        for (int i = 0; i < vset.size(); i++) {
            RDFNode v = vset.get(i);
            this.tivs.put(i, v);
        }
    }
    
    public Vector<Resource> getInstance(){
        
        Enumeration<Resource> e = this.keys();
        Vector<Resource> rset = new Vector<Resource>();
        while(e.hasMoreElements()){
            Resource r = e.nextElement();
            rset.add(r);
        }        
        return rset;
    }
    
//    public void setTargetInstance(Resource r, RDFNode value){
//        
//    }
    
    
    public TargetInstanceSet(Vector<Resource> posInstance, Vector<Resource> negInstance){
        for (int i = 0; i < posInstance.size(); i++) {
//            System.out.println("positive instance = " + posInstance.get(i));
//            this.put(posInstance.get(i), Boolean.TRUE);
            this.put(posInstance.get(i), 0);
            this.positive++;
        }
        
        for (int j = 0; j < negInstance.size(); j++) {
//            System.out.println("negative instance = " + negInstance.get(j));
//            this.put(negInstance.get(j), Boolean.FALSE);
            this.put(negInstance.get(j), 1);
            this.negative++;
        }
    }
    
    
    
    public void printTargetInstanceSet(){        
        Enumeration<Resource> e = this.keys();
        while(e.hasMoreElements()){
            
            Resource r = e.nextElement();
            int v = this.get(r);
            System.out.println("Instance name : " + r + " , target id : "+ v +"/ target value : "+ this.tivs.get(v).asLiteral().getLexicalForm());            
            
//            boolean b = this.get(r);            
//            System.out.println("Instance name : " + r + " , target value : "+ b);
        }
        
    }
    
    
}
